﻿@addTagHelper *, WebVella.Erp.Plugins.Core
@addTagHelper *, WebVella.Erp.Web
@addTagHelper *, WebVella.TagHelpers
@using WebVella.Erp.Web.Utils;
@using WebVella.Erp.Web.Components;
@using WebVella.Erp.Web.Models;
@using WebVella.TagHelpers.Models;
@{
	var options = (PcFieldDataCsv.PcFieldDataCsvOptions)ViewBag.Options;
	var node = (PageBodyNode)ViewBag.Node;
	var fieldModel = (PcFieldDataCsv.PcFieldBaseModel)ViewBag.Model;
	var labelMode = (WvLabelRenderMode)ViewBag.LabelMode;
	var mode = (WvFieldRenderMode)ViewBag.Mode;
	var delimiter = (WvCsvDelimiterType)ViewBag.Delimiter;
	var hasHeader = (bool?)ViewBag.HasHeader;
	var hasHeaderColumn = (bool?)ViewBag.HasHeaderColumn;
	if (String.IsNullOrWhiteSpace(fieldModel.ApiUrl))
		fieldModel.ApiUrl = $"/api/v3/en_US/record/{fieldModel.EntityName}/{fieldModel.RecordId}";
}
<div class="p-1">
	<wv-field-data-csv label-mode="@labelMode" label-text="@options.LabelText" label-warning-text="@fieldModel.LabelWarningText"
							 label-error-text="@fieldModel.LabelErrorText" label-help-text="@fieldModel.LabelHelpText" field-id="@fieldModel.FieldId"
							 name="@options.Name" class="@options.Class" value="@fieldModel.Value" mode="@mode" access="@fieldModel.Access"
							 init-errors="@fieldModel.InitErrors" validation-errors="@fieldModel.ValidationErrors.ToKeyValuePair()"
							 api-url="@fieldModel.ApiUrl" access-denied-message="@fieldModel.AccessDeniedMessage"
							 empty-value-message="@fieldModel.EmptyValueMessage" required="@fieldModel.Required" placeholder="@fieldModel.Placeholder"
							 description="@fieldModel.Description" locale="@fieldModel.Locale" height="@options.Height"
							 delimiter-value="@delimiter" lang="@ViewBag.Lang" has-header-value="@hasHeader" has-header-column-value="@hasHeaderColumn"
							 delimiter-field-name="@options.DelimiterFieldName" has-header-field-name="@options.HasHeaderFieldName" has-header-column-field-name="@options.HasHeaderColumnFieldName"></wv-field-data-csv>
</div>